#include <iostream>
#include <string>

bool is_correct_bracket(std::string text)
{
    while (true)
    {
        int count = 0;
        for (int i = 0; i < text.length(); i++)
        {
            if (text[i] == '(' && text[i + 1] == ')')
            {
                text.erase(i, 2);
                i = count;
                count = 0;
            }
            else if (text[i] == '{' && text[i + 1] == '}')
            {
                text.erase(i, 2);
                i = count;
                count = 0;
            }
            else if (text[i] == '[' && text[i + 1] == ']')
            {
                text.erase(i, 2);
                i = count;
                count = 0;
            }
            else
            {
                count++;
            }
        }

        if (count == text.length()) break;
    }

    return text.empty();
}

int main()
{
    std::string txt;
    std::cout << "Enter text: ";
    std::getline(std::cin, txt);
    std::cout << std::boolalpha << is_correct_bracket(txt) << std::endl;
    return 0;
}
